﻿using ETWJ.DTO;
using ETWJ.Iservice;
using ETWJ.Model;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace ETWJ.Service
{
    public class PublicCommissionService<TEntity, TDTO, TDbCtx>
        where TEntity:BaseModel//
        , ICommissionService
        where TDbCtx : MyDbContext, new()
    {
        public virtual async Task<int> AddNewAsync(TEntity dto)
        {
            TEntity en = AutoMapper.Mapper.Map<TEntity>(dto);
            using (TDbCtx ctx = new TDbCtx())
            {
                await ctx.Set<TEntity>().AddAsync(en);
                return await ctx.SaveChangesAsync();
            }
        }
    }
   
}
